
#include <mockcpp/mockcpp.hpp>
#include <testngpp/testngpp.hpp>
#include <Shape.h>
#include <Square.h>

USING_MOCKCPP_NS
USING_TESTNGPP_NS

FIXTURE(Square)
{
	TEST(should be able to calculate the area of Square: 3.351^2 = 11.22)
	{
		Square square(3.351); 
		ASSERT_EQ(11.22, square.getArea());
	}
        TEST(should be able to calculate the perimeter of Rectangle: 4*3.351=13.40)
        {
                Square square(3.351);
                ASSERT_EQ(13.40, square.getPerimeter());
        }

        TEST(should get 0 if length is invalid when caculate area: length<=0)
        {
                Square square(0.008);
                ASSERT_EQ(0, square.getArea());
        }
        TEST(should get 0 if length is invalid when caculate perimeter: length<=0)
        {
                Square square(0.008);
                ASSERT_EQ(0, square.getPerimeter());
        }
        TEST(should get 0 if length is invalid when caculate area: length>=75.0)
        {
                Square square(75.001);
                ASSERT_EQ(0, square.getArea());
        }
        TEST(should get 0 if length is invalid when caculate perimeter: length>=75.0)
        {
                Square square(75.001);
                ASSERT_EQ(0, square.getPerimeter());
        }

        TEST(Reset Square with valid rectangle: width = 9.456)
        {
                Square square(0);
                ASSERT_EQ(0, square.getPerimeter());
                ASSERT_EQ(0, square.getArea());
                Square squareTemp(9.456);
                square.reset( squareTemp);
                ASSERT_EQ(37.80, square.getPerimeter());
                ASSERT_EQ(89.30, square.getArea());
        }

        TEST(Reset Square with invalid rectangle: width = 0.0)
        {
                Square square(9.458);
                ASSERT_EQ(37.80, square.getPerimeter());
                ASSERT_EQ(89.30, square.getArea());
                Square squareTemp(0.0);
                square.reset( squareTemp);
                ASSERT_EQ(37.80, square.getPerimeter());
                ASSERT_EQ(89.30, square.getArea());
        }
};
